package com.tt.service;

import java.util.List;
import java.util.Set;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tt.dao.AdminDaoImpl;
import com.tt.entity.Page;
import com.tt.entity.Strategy;
import com.tt.entity.User;

import sun.net.www.content.text.plain;
@Service
public class AdminserviceImpl {
	@Resource
	private AdminDaoImpl aDaoImpl;
	
	//登录
	public boolean getloginadmin(String username,String password){
		if (this.aDaoImpl.loginAdmin(username, password)) {
			return true;
		} else {
			return false;
		}
		
	}
	//查看所有已发布拾光动态
	public Page<Strategy> findAll(int pageNum,int pageSize){
		return aDaoImpl.findAll(pageNum, pageSize);
	}
	//发布动态的用户
	public Set<Strategy> save(int id){
		User user=aDaoImpl.save(id);
		Set<Strategy> strategys = user.getStrategys();
		return strategys;
		
	}
	//删除已发布拾光动态
	 public boolean deleteStrategyt(int id) {
			aDaoImpl.deleteStrategyt(id);
			return true;
		}
	//查看所有用户信息
	public Page<User>findAll2(int pageNum,int pageSize){
		return aDaoImpl.findAll2(pageNum, pageSize);
		
	}
	//删除用户
	public boolean deleteUser(int id) {
		aDaoImpl.deleteUser(id);
		return true;
		
	}
	//判断用户成为为商家
	public void updateUser(User p){
		aDaoImpl.updateUser(p);
	}
	//获取用户id
	public User sUser(int id) {
		User user = aDaoImpl.save(id);
		return user;
		
	}
	//显示升级为商家的用户信息
	  public Page<User>findAll3(int pageNum,int pageSize,Integer uid){
		return aDaoImpl.findAll3(pageNum, pageSize, uid);
		  
	  }
}
